Skip to content

Add store-auth source and auto fallback to store list#7714

Open
dmerand wants to merge 1 commit into
donald/store-list-local-auth-seamfrom
donald/store-list-local-fallback
Open

Add store-auth source and auto fallback to store list#7714
dmerand wants to merge 1 commit into
donald/store-list-local-auth-seamfrom
donald/store-list-local-fallback

Conversation

@dmerand

@dmerand dmerand commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Add the --from source selector and auto fallback to shopify store list on top of #7709.

Demo:

Screen Recording 2026-06-05 at 11.08.13 AM.mov (uploaded via Graphite)

Closes https://github.com/shop/issues-develop/issues/22919

Scope

  • add --from auto | organization | store-auth (default auto)
  • add store-auth source, backed by listStoredStoreAuthSummaries(), rendered as Subdomain | Connected; its JSON carries only store + connectedAt (no user id / email)
  • make auto prefer your Shopify organization and fall back to locally stored store auth whenever the organization can't be listed for the current CLI session (not signed in, session not resolvable, reauthentication required, or any auth/network/listing error)
  • keep --from organization strict: no fallback, original error surfaced
  • thread noPrompt through ensureAuthenticatedBusinessPlatform() so auto can probe without prompting
  • carry --organization-id through auto/organization; reject it with --from store-auth; an unknown org id is a hard error in every mode (no silent fallback)
  • extend the 250 cap + truncation warning to the store-auth source; sort store-auth newest-first by connected date

Contract

  • result discriminant is organization | store-auth; no "Business Platform" wording in the command contract or output
  • every organization-listing failure is classified unavailable (original error preserved) so auto always falls back while --from organization rethrows

Smoke checks

  • logged out, store list → falls back to store-auth, exits 0
  • store list --from store-auth → local store auth table, exits 0
  • store list --from organization → strict, surfaces the failure

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Jun 4, 2026
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 89f393a to 619636c Compare June 5, 2026 13:41
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 1e3e4bc to 770846a Compare June 5, 2026 13:41
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 619636c to 7c049c1 Compare June 5, 2026 14:10
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 770846a to 95d8a71 Compare June 5, 2026 14:10
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 7c049c1 to 52daf1c Compare June 5, 2026 14:24
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 95d8a71 to 04f35fd Compare June 5, 2026 14:24
@dmerand dmerand changed the title Add local source and auto fallback to store list Add store-auth source and auto fallback to store list Jun 5, 2026

dmerand commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor

/snapit

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @nickwesselman! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260605172558

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 04f35fd to 065f5fa Compare June 5, 2026 18:12
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch 2 times, most recently from 00dce2a to 22e4f4a Compare June 5, 2026 18:31
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch 4 times, most recently from c8eed6e to aa58407 Compare June 5, 2026 19:06
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 22e4f4a to 31a07f1 Compare June 5, 2026 19:06
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 451e239 to bc75901 Compare June 8, 2026 18:41
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch 2 times, most recently from c128517 to 9343914 Compare June 8, 2026 19:06
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch 2 times, most recently from a57b2f7 to 996a184 Compare June 8, 2026 19:10
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 9343914 to 81229e4 Compare June 8, 2026 19:10
@dmerand dmerand marked this pull request as ready for review June 8, 2026 20:56
@dmerand dmerand requested review from a team as code owners June 8, 2026 20:56
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 996a184 to dd7e4fc Compare June 8, 2026 21:08
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch 2 times, most recently from 04b87d7 to b3f03fe Compare June 10, 2026 14:34
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from dd7e4fc to d137536 Compare June 10, 2026 14:34
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from b3f03fe to 6246aef Compare June 10, 2026 15:00
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from d137536 to 7e91272 Compare June 10, 2026 15:00
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 6246aef to 48744ec Compare June 10, 2026 19:31
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 7e91272 to 78815d1 Compare June 10, 2026 19:31
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 48744ec to f448d62 Compare June 10, 2026 19:50
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 78815d1 to 27f2765 Compare June 10, 2026 19:50
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from f448d62 to 97f1e30 Compare June 11, 2026 00:45
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 27f2765 to be39f2a Compare June 11, 2026 00:45
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 97f1e30 to d711b7b Compare June 11, 2026 01:07
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from be39f2a to 3ce15df Compare June 11, 2026 01:07
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from d711b7b to 592ab5b Compare June 11, 2026 01:17
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 3ce15df to 8fc4a79 Compare June 11, 2026 01:17
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 592ab5b to cc8b9c3 Compare June 11, 2026 01:27
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 8fc4a79 to df6e5d1 Compare June 11, 2026 01:27
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from cc8b9c3 to 0d54c55 Compare June 11, 2026 01:43
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from df6e5d1 to fbc732b Compare June 11, 2026 01:43
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 0d54c55 to ca16bf5 Compare June 11, 2026 02:01
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from fbc732b to 7674c38 Compare June 11, 2026 02:01
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from ca16bf5 to ed03486 Compare June 11, 2026 02:11
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 7674c38 to 1cb0d3f Compare June 11, 2026 02:11
Adds `--from auto|organization|store-auth`. `auto` (default) prefers the
Shopify organization listing and falls back to locally stored store auth when
the organization can't be listed for the current CLI session. Adds the
store-auth source/local-source, the discriminated result contract, and the
unavailable status that drives the fallback.
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from ed03486 to 8d4afd4 Compare June 11, 2026 02:22
@dmerand dmerand force-pushed the donald/store-list-local-fallback branch from 1cb0d3f to 0c933e5 Compare June 11, 2026 02:22
@github-actions

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/common/string.d.ts
@@ -102,6 +102,16 @@ export declare function formatDate(date: Date): string;
  * @returns The transformed string in local system time.
  */
 export declare function formatLocalDate(dateString: string): string;
+/**
+ * Formats a date as a short calendar date like "May 22, 2026" () in UTC.
+ *
+ * UTC keeps the output deterministic regardless of the machine timezone. Returns an empty string
+ * when the value cannot be parsed into a valid date.
+ *
+ * @param value - A Date, epoch milliseconds, or a date string such as an ISO 8601 timestamp.
+ * @returns The formatted date, or an empty string when the value is invalid.
+ */
+export declare function formatShortDate(value: Date | number | string): string;
 /**
  * Given a list of items, it returns a string with the items joined by commas and the last item joined by "and".
  * All items are wrapped in double quotes.
packages/cli-kit/dist/public/common/url.d.ts
@@ -28,4 +28,13 @@ export declare function extractHost(value: string | null | undefined): string |
  * @param value - A URL or host string, possibly null/undefined.
  * @returns The myshopify subdomain handle, or undefined when the input isn't a  URL.
  */
-export declare function extractMyshopifyHandle(value: string | null | undefined): string | undefined;
\ No newline at end of file
+export declare function extractMyshopifyHandle(value: string | null | undefined): string | undefined;
+/**
+ * Extracts the leading subdomain label from a URL or host, across environments — e.g.
+ * , , or local development hosts — rather than assuming a
+ *  domain.
+ *
+ * @param value - A URL or host string, possibly null/undefined.
+ * @returns The first DNS label, or undefined when no host can be extracted.
+ */
+export declare function extractSubdomain(value: string | null | undefined): string | undefined;
\ No newline at end of file
packages/cli-kit/dist/public/node/metadata.d.ts
@@ -38,7 +38,6 @@ type CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> & Pic
 declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
     commandStartOptions: {
         startTime: number;
-        endTime?: number;
         startCommand: string;
         startTopic?: string;
         startArgs: string[];
@@ -59,7 +58,6 @@ declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
 export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>, getAllSensitiveMetadata: () => Partial<{
     commandStartOptions: {
         startTime: number;
-        endTime?: number;
         startCommand: string;
         startTopic?: string;
         startArgs: string[];
@@ -79,7 +77,6 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
 }, "store_", never>>, addPublicMetadata: (getData: ProvideMetadata<CmdFieldsFromMonorail>, onError?: MetadataErrorHandling) => Promise<void>, addSensitiveMetadata: (getData: ProvideMetadata<{
     commandStartOptions: {
         startTime: number;
-        endTime?: number;
         startCommand: string;
         startTopic?: string;
         startArgs: string[];
packages/cli-kit/dist/public/node/session.d.ts
@@ -119,9 +119,10 @@ export declare function ensureAuthenticatedThemes(store: string, password: strin
  * Ensure that we have a valid session to access the Business Platform API.
  *
  * @param scopes - Optional array of extra scopes to authenticate with.
+ * @param options - Optional auth behavior overrides such as .
  * @returns The access token for the Business Platform API.
  */
-export declare function ensureAuthenticatedBusinessPlatform(scopes?: BusinessPlatformScope[]): Promise<string>;
+export declare function ensureAuthenticatedBusinessPlatform(scopes?: BusinessPlatformScope[], options?: EnsureAuthenticatedAdditionalOptions): Promise<string>;
 /**
  * Logout from Shopify.
  *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants